package cvsexample4;

public class MultidimensionalArray {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	
		/* Write out a start message to the console */
		System.out.println("Example 4 - Basic Multidimensional Arrays started");
		
		/* Declare and initialize an 2x2 array (M x N) of integers
		    Don't use an initializer list! */
		int[][] my2DArray = new int[2][2];
		
		/* Populate the first row of the array with the values 10, 20 */
		my2DArray[0][0] = 10;
		my2DArray[0][1] = 20;
		
		/* Populate the second row of the array with the values 30, 40 */
		my2DArray[1][0] = 30;
		my2DArray[1][1] = 40;
		
		/* Use the array's length property to output the length of the first row */
		int nLength = my2DArray[0].length;
		System.out.println("Length of my2DArray[] (row 0) = " + nLength);
		
		/* Use the array's length property to output the length of the second row */
		nLength = my2DArray[1].length;
		System.out.println("Length of my2DArray[] (row 1) = " + nLength);
		
		/* Write out the each values in each row of the array */
		System.out.println("Row 0 values = " + my2DArray[0][0] + "," + my2DArray[0][1]);
		System.out.println("Row 1 values = " + my2DArray[1][0] + "," + my2DArray[1][1]);
		
		/* Write out the each values in each column of the array */
		System.out.println("Column 0 values = " + my2DArray[0][0] + "," + my2DArray[1][0]);
		System.out.println("Column 1 values = " + my2DArray[0][1] + "," + my2DArray[1][1]);	
		
		/* Write out a completed message to the console */
		System.out.println("Example 4 - Multidimensional Arrays completed");
	}
}
